import { createRouter, createWebHistory } from "vue-router";
import HomeView from "../views/HomeView.vue";

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: "/",
      name: "Login",
      component: () => import("../views/LoginView.vue"),
    },
    // {
    //   path: "/Login",
    //   name: "Login",
    //   component: () => import("../views/LoginView.vue"),
    // },
    {
      path: "/main",
      name: "main",
      component: () => import("../views/MainView.vue"),
      children: [
        {
          path: "/RBACFile/RoleView",
          name: "RoleView",
          component: () => import("../views/RBACFile/RolesView.vue"),
        },
        {
          path: "/RBACFile/PermissionView",
          name: "PermissionView",
          component: () => import("../views/RBACFile/PermissionView.vue"),
        },
        {
          path: "/PurchasingManagement/SupplierView",
          name: "SupplierView",
          component: () =>
            import("../views/PurchasingManagement/SupplierView.vue"),
        },
        {
          path: "/Warehouses/WarehouseListView",
          name: "WarehouseListView",
          component: () => import("../views/Warehouses/WarehouseListView.vue"),
        },
        {
          path: "/SalesOrderAddView",
          name: "SalesOrderAddView",
          component: () => import("../views/SalesOrder/SalesOrderAddView.vue"),
        },
        {
          path: "/PurchasingManagement/SupplierView",
          name: "SupplierView",
          component: () =>
            import("../views/PurchasingManagement/SupplierView.vue"),
        },
        {
          path: "/Warehouses/WarehouseListView",
          name: "WarehouseListView",
          component: () => import("../views/Warehouses/WarehouseListView.vue"),
        },
        {
          path: "/CustomerProfiles/CustomerProfileListView",
          name: "CustomerProfileListView",
          component: () =>
            import("../views/CustomerProfiles/CustomerProfileListView.vue"),
        },

        //物料分类
        {
          path: "/Material/MaterialListView",
          name: "MaterialListView",
          component: () => import("../views/Material/MaterialListView.vue"),
        },
        //物料基本档
        {
          path: "/Material/MaterialessentialView",
          name: "MaterialessentialView",
          component: () =>
            import("../views/Material/MaterialessentialView.vue"),
        },
        //销售订单明细显示
        {
          path: "/SalesOrderListShow",
          name: "SalesOrderListShow",
          component: () => import("../views/SalesOrder/SalesOrderListShow.vue"),
        },
        //发货通知单新增
        {
          path: "/SalesOrder/DeliverynoticeAdd",
          name: "DeliverynoticeAdd",
          component: () =>
            import("../views/SalesOrder/DeliverynoticeAddView.vue"),
        },
        //发货通知单列表
        {
          path: "/SalesOrder/DeliverynoticeShow",
          name: "DeliverynoticeShow",
          component: () => import("../views/SalesOrder/DeliverynoticeView.vue"),
        },
        //部门添加
        {
          path: "/Department/DepartmentAddView",
          name: "DepartmentAddView",
          component: () => import("../views/Department/DepartmentAddView.vue"),
        },
        //销售订单单据显示
        {
          path: '/SalesOrderdanjuShow',
          name: 'SalesOrderdanjuShow',
          component: () => import('../views/SalesOrder/SalesOrderdanjuShow.vue')
        },
        //销售订单查看
        {
          path: '/SalesOrderIntail',
          name: 'SalesOrderIntail',
          component: () => import('../views/SalesOrder/SalesOrderIntail.vue')
        },
        //采购订单
        {
          path: '/PurchasingManagement/PurchaseOrde',
          name: 'PurchaseOrde',
          component: () => import('../views/PurchasingManagement/PurchaseOrde.vue')
        },
        //添加采购订单
        {
          path: '/PurchasingManagement/PurchaseOrdeAdd',
          name: 'PurchaseOrdeAdd',
          component: () => import('../views/PurchasingManagement/PurchaseOrdeAdd.vue')
        },
        //采购发票列表
        {
          path: "/PurchaseInvoices/PurchaseInvoicesListView",
          name: "PurchaseInvoicesListView",
          component: () => import("../views/PurchaseInvoices/PurchaseInvoicesListView.vue"),
        },
        //采购发票新增
        {
          path: "/PurchaseInvoices/PurchaseInvoicesAddView",
          name: "PurchaseInvoicesAddView",
          component: () => import("../views/PurchaseInvoices/PurchaseInvoicesAddView.vue"),
        },
        //开票通知单新增
        {
          path: "/Invoicingmemo/AddBillingView",
          name: "AddBillingView",
          component: () =>
            import("../views/Invoicingmemo/AddBillingView.vue"),
        },
        //开票通知单显示
        {
          path: "/Invoicingmemo/BillingListView",
          name: "BillingListView",
          component: () =>
            import("../views/Invoicingmemo/BillingListView.vue"),
        },
        //开票通知单编辑
        {
          path: "/Invoicingmemo/UpdateBillingView",
          name: "UpdateBillingView",
          component: () =>
            import("../views/Invoicingmemo/UpdateBillingView.vue"),
        },
        //销售出库订单新增
        {
          path: "/SaleOutOfWarehouse",
          name: "SaleOutOfWarehouse",
          component: () =>
            import("../views/OutOfStock/SaleOutOfWarehouse.vue"),
        },
        //销售出库明细表
        {
          path: "/SaleOutSearchView",
          name: "SaleOutSearchView",
          component: () =>
            import("../views/OutOfStock/SaleOutSearchView.vue"),
        },
        //销售出库单据表
        {
          path: "/SaleOutSearchdanjuShow",
          name: "SaleOutSearchdanjuShow",
          component: () =>
            import("../views/OutOfStock/SaleOutSearchdanjuShow.vue"),
        },
        //销售出库查看
        {
          path: "/SaleOutSearchDeclia",
          name: "SaleOutSearchDeclia",
          component: () =>
            import("../views/OutOfStock/SaleOutSearchDeclia.vue"),
        },

        //发货通知查看
        {
          path: "/SalesOrder/DeliverynoticeEditView",
          name: "DeliverynoticeEditView",
          component: () =>
            import("../views/SalesOrder/DeliverynoticeEditView.vue"),
        },
        {
          path: "/PurchaseWarehousingAdd",
          name: "PurchaseWarehousingAdd",
          component: () =>
            import("../views/PurchaseWarehousing/PurchaseWarehousingAdd.vue"),
        },
        {
          path: "/PurchaseWarehousingShow",
          name: "PurchaseWarehousingShow",
          component: () =>
            import("../views/PurchaseWarehousing/PurchaseWarehousingShow.vue"),
        },
        //采购到货单
        {
          path: "/PurchasingManagement/PurchasedGoods",
          name: "PurchasedGoods",
          component: () =>
            import("../views/PurchasingManagement/PurchasedGoods.vue"),
        },
        {
          path: "/PurchasingManagement/PurchasedGoodsAdd",
          name: "PurchasedGoodsAdd",
          component: () =>
            import("../views/PurchasingManagement/PurchasedGoodsAdd.vue"),
        },
        //采购退货订单新增
        {
          path: "/PurchaseReturnOrders/PurchaseReturnOrderAddView",
          name: "PurchaseReturnOrderAddView",
          component: () =>
            import("../views/PurchaseReturnOrders/PurchaseReturnOrderAddView.vue"),
        },
        //采购退货订单列表
        {
          path: "/PurchaseReturnOrders/PurchaseReturnOrderListView",
          name: "PurchaseReturnOrderListView",
          component: () =>
            import("../views/PurchaseReturnOrders/PurchaseReturnOrderListView.vue"),
        },
        {
          path: "/PurchaseWarehousingDanjuShow",
          name: "PurchaseWarehousingDanjuShow",
          component: () =>
            import("../views/PurchaseWarehousing/PurchaseWarehousingDanjuShow.vue"),
        },
        {
          path: "/PurchaseWarehousingSeiadal",
          name: "PurchaseWarehousingSeiadal",
          component: () =>
            import("../views/PurchaseWarehousing/PurchaseWarehousingSeiadal.vue"),
        },
        //反填采购订单
        {
          path: '/PurchasingManagement/PurchaseOrdeEdit',
          name: 'PurchaseOrdeEdit',
          component: () => import('../views/PurchasingManagement/PurchaseOrdeEdit.vue')
        },
        //退货通知单新增
        {
          path: "/ReturnNotice/AddReturnNoticeView",
          name: "AddReturnNoticeView",
          component: () =>
            import("../views/ReturnNotice/AddReturnNoticeView.vue"),
        },
        //退货通知单列表
        {
          path: "/ReturnNotice/ReturnNoticeListView",
          name: "ReturnNoticeListView",
          component: () =>
            import("../views/ReturnNotice/ReturnNoticeListView.vue"),
        },
        //退货通知单编辑
        {
          path: "/ReturnNotice/UpdateReturnNoticeView",
          name: "UpdateReturnNoticeView",
          component: () =>
            import("../views/ReturnNotice/UpdateReturnNoticeView.vue"),
        },
        //退货通知单编辑
        {
            path: "/ReturnNotice/UpdateReturnNoticeView",
            name: "UpdateReturnNoticeView",
            component: () =>
              import("../views/ReturnNotice/UpdateReturnNoticeView.vue"),
        },
        //查看采购退货单
        {
          path: "/PurchaseReturnOrders/PurchaseReturnOrderDetailView",
          name: "PurchaseReturnOrderDetailView",
          component: () =>
            import("../views/PurchaseReturnOrders/PurchaseReturnOrderDetailView.vue"),
        },
        //反填采购订单
        {
          path: '/PurchasingManagement/PurchaseOrdeEdit',
          name: 'PurchaseOrdeEdit',
          component: () => import('../views/PurchasingManagement/PurchaseOrdeEdit.vue')
        },
        //发货通知单明细
        {
          path: '/ShipmentsTZD/shipmentsDetails',
          name: 'shipmentsDetails',
          component: () => import('../views/ShipmentsTZD/shipmentsDetails.vue')
        },
        {
          path: "/PurchaseReturnOrders/PurchaseReturnOrderDetailView",
          name: "PurchaseReturnO        rderDetailView",
          component: () =>
            import("../views/PurchaseReturnOrders/PurchaseReturnOrderDetailView.vue"),
        },
        {
          path: '/PurchasingManagement/PurchaseOrdeEdit',
          name: 'PurchaseOrdeEdit',
          component: () => import('../views/PurchasingManagement/PurchaseOrdeEdit.vue')
        },
        //采购发票明细
        {
          path: '/PurchasingManagement/PurchaseInvoiceDetail',
          name: 'PurchaseInvoiceDetail',
          component: () => import('../views/PurchasingManagement/PurchaseInvoiceDetail.vue')
        },
        {
          path: '/PurchasingManagement/PurchaseOutWarehouseDetails',
          name: 'PurchaseOutWarehouseDetails',
          component: () => import('../views/PurchasingManagement/PurchaseOutWarehouseDetails.vue')
        },
        //开票通知单明细
        {
          path: '/Invoicingmemo/BillingDetailsView',
          name: 'BillingDetailsView',
          component: () => import('../views/Invoicingmemo/BillingDetailsView.vue')
        },
        //销售订单明细
        {
          path: '/ShipmentsTZD/SeleteOrder',
          name: 'SeleteOrder',
          component: () => import('../views/ShipmentsTZD/SeleteOrderView.vue')
        },
        //采购入库明细
        {
          path: '/PurchaseWarehousingDelads',
          name: 'PurchaseWarehousingDelads',
          component: () => import('../views/PurchaseWarehousing/PurchaseWarehousingDelads.vue')
        },
        //出入库明细
        {
          path: '/Churuku',
          name: 'Churuku',
          component: () => import('../views/PurchaseWarehousing/Churuku.vue')
        },

        //PurchaseInvoices 查看采购发票
        {
          path: '/PurchaseInvoices/PurchaseInvoicesDetailView',
          name: 'PurchaseInvoicesDetailView',
          component: () => import('../views/PurchaseInvoices/PurchaseInvoicesDetailView.vue')
        },
        //退货通知明细
        {
          path:'/ReturnNotice/ReturnDetaliView',
          name:'ReturnDetaliView',
          component:()=>import('../views/ReturnNotice/ReturnDetaliView.vue')
        },
        //7天发货明细表
        {
          path:'/ShipmentsTZD/DeliveGoodsView',
          name:'DeliveGoodsView',
          component:()=>import('../views/ShipmentsTZD/DeliveGoodsView.vue')
        },
        //采购订单明细报表
        {
          path:'/PurchasingManagement/PurchasedOrderReportView',
          name:'PurchasedOrderReportView',
          component:()=>import('../views/PurchasingManagement/PurchasedOrderReportView.vue')
        },
        //日志列表
        {
          path:'/LogsList/LogListView',
          name:'LogListView',
          component:()=>import('../views/LogsList/LogListView.vue')
        }
      ],
    },
  ],
});
import { useCounterStore } from '@/stores/counter';
//导航守卫
router.beforeEach((to, from, next) => {
  // if (to.name !== 'login' && localStorage.getItem("isLogin")!="true") next({ name: 'login' })
  // else next()

  const useStore = useCounterStore();
  let isAuthentcated = useStore.isLogin;
  if (to.name !== "Login" && !isAuthentcated) next({ name: "Login" })
  else next()
})
export default router;
